﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Vit.Common
{
    public class LogInfo
    {
        public LogInfo()
            : this(null, null, LogLevel.Info)
        {
        }

        public LogInfo(string source, string message)
            : this(source, message, LogLevel.Info)
        {
            Source = source;
            Message = message;
        }

        public LogInfo(string source, string message, LogLevel logLevel)
        {
            Source = source;
            Message = message;
            LogLevel = logLevel;
            LogTime = DateTime.Now;
            if (HttpContext.Current != null)
                RequestUrl = HttpContext.Current.Request.RawUrl;
        }

        public LogInfo(Exception ex)
        {
            ex = ex.GetBaseException();
            Source = ex.Source;
            Message = ex.Message;
            Details = ex.StackTrace;
            LogLevel = LogLevel.Error;
            LogTime = DateTime.Now;
            if (HttpContext.Current != null)
                RequestUrl = HttpContext.Current.Request.RawUrl;
        }

        public string Source { get; set; }
        public string Message { get; set; }
        public string Details { get; set; }
        public string RequestUrl { get; set; }
        public LogLevel LogLevel { get; set; }
        public string ContextInfo { get; set; }

        public DateTime LogTime { get; set; }
    }
}
